<template>
	<u-checkbox-group @change="checkboxGroupChange">
		<u-checkbox v-for="(checkItem, checkIndex) in range" v-model="checkedObj[checkItem.value]" :key="checkIndex.value"
			:name="checkItem.value">
			{{ checkItem.label }}
		</u-checkbox>
	</u-checkbox-group>
</template>

<script setup>
	import {
		ref,
		reactive,
		computed,
		watch,
		onMounted
	} from 'vue'
	import mixins from '@/common/js/mixins.js'; //需要引入store
	const props = defineProps({
		modelValue: {
			type: [String, Number, Array],
			default: '',
		},
		range: {
			type: Array,
			default: [],
		},
	})
	const checkedObj = computed(()=>{
		let obj = {};
		if(props.modelValue.length>0){
			props.modelValue.forEach(v=>{
				obj[v] = true
			})
		}
		return obj
	})
	onMounted(() => {
		

	})
	watch(
		() => props.modelValue,
		newValue => {
			
		}
	);

	const emit = defineEmits(['update:modelValue']);
	const checkboxGroupChange = (e) => {
		// console.log(e);
		let arr = []
		e.forEach(v=>{
			arr.push(v)
		})
		emit('update:modelValue', arr);

	}
</script>

<style lang="scss" scoped>
	
</style>